package org.example;

import java.sql.*;

class Student {
    private int id;
    private String name;

    public int getId(){
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String Name) {
        this.name = Name;
    }
}

class Insert {
        //String inputName = "' or '1'='1";
        String sql = "insert into student values(1, '张三')";
        //System.out.println(sql);
        //ResultSet rs = s.executeQuery(sql);
}
class Delete {

        String sql = "delete from student where name = '张三'";
}
class Select {
        String sql = "select * from student";
}
class Update {

        String sql = "update student set id = id + 1 where name = '张三'";
}
public class First {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {

        Class.forName("com.mysql.jdbc.Driver");

        Connection c = DriverManager.getConnection("jdbc:mysql://localhost:3306/test?user=root&password=1433223&useUnicode=true&characterEncoding=UTF-8&useSSL=false");

        Statement s = c.createStatement();
        String sql;
        //System.out.println(sql);
        //ResultSet rs = s.executeQuery(sql);
        //while (rs.next()){
         //   int id = rs.getInt("c_id");
        //    String name = rs.getString("c_name");
         //   System.out.printf("id: %s, name: %s\n", id, name);
        //}

        //5.释放资源：反向释放（resultSet, Statement, Connection）.close()
    }
}